{% extends 'myadmin/base.html' %}
{% block main_body %}
<style>
    /* 紧凑布局核心样式 */
    .form-card {
        background: #fff;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        padding: 20px;
    }
    .form-section {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #f1f1f1;
    }
    .form-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    .form-section h4 {
        margin: 0 0 15px;
        font-size: 16px;
        color: #3c8dbc;
        display: flex;
        align-items: center;
    }
    .form-section h4 i {
        margin-right: 8px;
    }
    .form-row {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -10px; /* 抵消列的内边距 */
    }
    .form-col {
        flex: 1;
        min-width: 300px; /* 确保小屏幕下不挤压 */
        padding: 0 10px; /* 列之间的间距 */
        box-sizing: border-box;
    }
    .form-group {
        margin-bottom: 12px; /* 缩小字段间距 */
        width: 100%;
    }
    .form-group label {
        font-weight: 600;
        font-size: 13px;
        margin-bottom: 5px;
        display: block;
        width: 100%;
    }
    .form-control {
        border-radius: 4px;
        padding: 6px 10px;
        font-size: 13px;
        height: 34px;
        width: 100%; /* 输入框宽度100% */
        box-sizing: border-box; /* 包含内边距和边框 */
    }
    .help-text {
        font-size: 12px;
        color: #666;
        margin-top: 3px;
        display: block;
    }
    .required-mark {
        color: #dd4b39;
        margin-left: 3px;
    }
    .btn-group {
        margin-top: 15px;
        display: flex;
        gap: 10px;
        justify-content: flex-end;
        padding: 0 10px;
    }
    .btn {
        padding: 6px 15px;
        font-size: 13px;
    }
</style>

<section class="content-header">
    <h1>健康数据管理 <small>添加健康记录</small></h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-home"></i> 首页</a></li>
        <li><a href="#">健康数据管理</a></li>
        <li class="active">添加健康记录</li>
    </ol>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">健康记录录入</h3>
                </div>
                <form method="post" action="{% url 'myadmin_userbodyrecords_add' %}" class="form-card">
                    {% csrf_token %}
                    
                    <!-- 1. 基础记录信息 -->
                    <div class="form-section">
                        <h4><i class="fa fa-list-alt"></i> 基础记录信息</h4>
                        <div class="form-row">
                            <div class="form-col">
                                <div class="form-group">
                                    <label>用户ID <span class="required-mark">*</span></label>
                                    <input type="number" name="user_id" class="form-control" required>
                                    <span class="help-text">关联的用户ID</span>
                                </div>
                            </div>
                            <div class="form-col">
                                <div class="form-group">
                                    <label>记录日期 <span class="required-mark">*</span></label>
                                    <input type="date" name="record_date" class="form-control" required>
                                    <span class="help-text">记录健康数据的日期</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 2. 身体成分数据 -->
                    <div class="form-section">
                        <h4><i class="fa fa-balance-scale"></i> 身体成分数据</h4>
                        <div class="form-row">
                            <div class="form-col">
                                <div class="form-group">
                                    <label>体重(kg)</label>
                                    <input type="number" name="weight" class="form-control" min="10" max="300" step="0.1">
                                    <span class="help-text">保留1位小数</span>
                                </div>
                                <div class="form-group">
                                    <label>体脂率(%)</label>
                                    <input type="number" name="body_fat_percentage" class="form-control" min="0" max="100" step="0.1">
                                    <span class="help-text">保留1位小数</span>
                                </div>
                                <div class="form-group">
                                    <label>肌肉量(kg)</label>
                                    <input type="number" name="muscle_mass" class="form-control" min="0" max="200" step="0.1">
                                    <span class="help-text">保留1位小数</span>
                                </div>
                            </div>
                            <div class="form-col">
                                <div class="form-group">
                                    <label>水分率(%)</label>
                                    <input type="number" name="water_percentage" class="form-control" min="0" max="100" step="0.1">
                                    <span class="help-text">保留1位小数</span>
                                </div>
                                <div class="form-group">
                                    <label>骨量(kg)</label>
                                    <input type="number" name="bone_mass" class="form-control" min="0" max="30" step="0.1">
                                    <span class="help-text">保留1位小数</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 3. 血液指标数据 -->
                    <div class="form-section">
                        <h4><i class="fa fa-tint"></i> 血液指标数据</h4>
                        <div class="form-row">
                            <div class="form-col">
                                <div class="form-group">
                                    <label>收缩压(mmHg)</label>
                                    <input type="number" name="blood_pressure_systolic" class="form-control" min="50" max="200">
                                    <span class="help-text">正常范围：90-140</span>
                                </div>
                                <div class="form-group">
                                    <label>舒张压(mmHg)</label>
                                    <input type="number" name="blood_pressure_diastolic" class="form-control" min="30" max="120">
                                    <span class="help-text">正常范围：60-90</span>
                                </div>
                            </div>
                            <div class="form-col">
                                <div class="form-group">
                                    <label>血糖(mmol/L)</label>
                                    <input type="number" name="blood_sugar" class="form-control" min="2" max="20" step="0.1">
                                    <span class="help-text">空腹正常范围：3.9-6.1</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 4. 备注信息 -->
                    <div class="form-section">
                        <h4><i class="fa fa-sticky-note"></i> 备注信息</h4>
                        <div class="form-group">
                            <textarea name="notes" class="form-control" rows="3" placeholder="记录特殊情况或说明"></textarea>
                        </div>
                    </div>
                    
                    <!-- 操作按钮区 -->
                    <div class="btn-group">
                        <button type="button" class="btn btn-default" onclick="window.history.back();">
                            <i class="fa fa-arrow-left"></i> 返回
                        </button>
                        <button type="reset" class="btn btn-default">
                            <i class="fa fa-refresh"></i> 重置
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fa fa-check"></i> 保存记录
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
{% endblock %}